import 'dart:io';
import 'dart:convert';

final httpClient = new HttpClient();

getData({url,params}) async{
  var uri = new Uri.http(
    'api.help.bj.cn', 
    url,
    params
  );
  try {
    var request = await httpClient.getUrl(uri);
    var response = await request.close();
    var responseBody = await response.transform(utf8.decoder).join();
    Map data = json.decode(responseBody);
    return {
      'success': true,
      'result': data,
    };
  } catch(exception){
    return {
      'success': false,
      'reason': exception.toString()
    };
  }
}